import type { AppRouteRecordRaw } from 'store/interface/index';
import { RootStateTypes, StateTagsViewModule } from 'store/interface/index';
import { Module, ActionContext } from 'vuex';
import {
  ModuleState,
  ModuleGetters,
  ModuleActions,
  ModuleMutations
} from '../hooks';

const state: StateTagsViewModule  = {
	tagsView: [],
}

const getters = {}

const mutations = {
	// 设置 TagsView 路由
	getTagsView(state: StateTagsViewModule, data: Array<AppRouteRecordRaw>) {
		state.tagsView = data;
	},
}

const actions = {
	// 设置 TagsView 路由
	async setTagsView({ commit }: ActionContext<StateTagsViewModule, RootStateTypes>, data: Array<AppRouteRecordRaw>) {
		commit('getTagsView', data);
	},
}

type stateKey = typeof state
export type TagsViewState = ModuleState<stateKey>
type gettersKey = typeof getters
export type TagsViewGetters = ModuleGetters<gettersKey>
type mutationKey = typeof mutations
export type TagsViewMutations = ModuleMutations<mutationKey>
type actionKey = typeof actions
export type TagsViewActions = ModuleActions<actionKey>

const tagsViewModule: Module<StateTagsViewModule, RootStateTypes> = {
	namespaced: true,
	state,
  getters,
  mutations,
  actions
};

export default tagsViewModule;
